package example.prototypeBeanInjectSingleton;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class SingletonBean implements ApplicationContextAware {

	ApplicationContext context;

	@Autowired
	private PrototypeBean prototypeBean;


	public PrototypeBean getPrototypeBean() {
		return context.getBean(PrototypeBean.class);
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		context = applicationContext;
	}
}
